package com.seadragon.app.ksr.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

//@AnalyzerDef(name = "customeranalyzer", tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class), filters = {
//	@TokenFilterDef(factory = LowerCaseFilterFactory.class),
//	@TokenFilterDef(factory = StopFilterFactory.class, params = {
//			@Parameter(name = "words", value = "stopwords.txt"),
//			@Parameter(name = "ignoreCase", value = "true") }),
//	@TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = { @Parameter(name = "language", value = "English") }) })
//@Indexed(index = "Customer")
@SuppressWarnings("serial")
@Entity
@Table(name="CUSTOMER", schema="STAGING")
//@Table(name="CUSTOMER", uniqueConstraints = @UniqueConstraint(columnNames = {"lastName", "firstName", "dateOfBirth"}))
public class Customer implements Serializable{
	@Id
	@Column(name = "ID")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "CUSTOMERIDSEQ")
	@SequenceGenerator(name = "CUSTOMERIDSEQ", sequenceName = "STAGING.CUSTOMER_ID_SEQ", schema="STAGING")	
//	@DocumentId
	private Long id;

	@OneToOne(cascade=CascadeType.PERSIST)
	@JoinColumn(name="RESIDENT_ADDRESS_ID")
	private Address residentAddress;
	
	@Column(name="FIRST_NAME")
	private String firstName;
	
	@Column(name="LAST_NAME")
	private String lastName;
	
	@Column(name="EMAIL", nullable=false, unique=true)
	private String email;
	
	@Column(name="INTEREST")
//	@Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO)
	private String interest;
	
	@Column(name="PHONE_NUMBER")
	private String phoneNumber;
	
	@Column(name="PASSWORD")
	private String password;
	
	@Column(name="date_of_birth")
	@Temporal(TemporalType.DATE)
//	@Field(index = Index.YES, analyze = Analyze.NO) 
//	@DateBridge(resolution = Resolution.YEAR)
	private Date dateOfBirth;
	
	@OneToMany(mappedBy="customer")
	private List<Review> reviews;
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public Address getResidentAddress() {
		return residentAddress;
	}

	public void setResidentAddress(Address residentAddress) {
		this.residentAddress = residentAddress;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getInterest() {
		return interest;
	}

	public void setInterest(String interest) {
		this.interest = interest;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public Date getDateOfBirth() {
		return dateOfBirth;
	}

	public void setDateOfBirth(Date dateOfBirth) {
		this.dateOfBirth = dateOfBirth;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public List<Review> getReviews() {
		return reviews;
	}

	public void setReviews(List<Review> reviews) {
		this.reviews = reviews;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
}
